<script type="text/javascript">
    $(document).ready(function() {

        $("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
            submitSuccess: function($form, event) {
                event.preventDefault();
                //alert("success");

                $.ajax({
                    type: "POST",
                    url: "debtor_group_process.php",
                    data: $('#frm_main').serialize(),
                    cach: false,
                    error: function() {
                        alert("ERROR !!!!");
                    },
                    success: function(data) {

//                        if (confirm("คุณต้องการพิมพ์ฎีกาหรือไม่")) {
//                            window.location.href = "index.php?pages=v_budget";
//                        } else {
//                            window.location.href = "index.php?pages=v_budget";
//                        }
                        //$("#dispStatus").html(data);
                        //alert(data);
                        window.location.href = "index.php?pages=debtor_group";

                    }
                });
            }
        });
    });


</script>
<?php
$id = $_REQUEST["id"];

$db = new myDBS();

if ($id) {
    $sql = "select * from tbl_debtor_group where id='$id'";
    $row = $db->fetch_object($db->runSQL($sql));
}
?>

<div id="dispStatus"></div>
<form class="form-horizontal" id="frm_main" name="frm_main" method="post">
    
    <input type="hidden" id="task" name="task" value="<?php echo ($id)? "edit":"new"; ?>">
    <input type="hidden" id="id" name="id" value="<?php echo $id; ?>">
    <div class="panel panel-info">
        <div class="panel-heading">กลุ่มลูกหนี้</div>
        <div class="panel-body">

            <div class="control-group">
                <label class="control-label" for="กลุ่มลูกหนี้">กลุ่มลูกหนี้</label>
                <div class="controls">
                    <input type="text" id="group_name" name="group_name" value="<?php echo $row->group_name; ?>">
                </div>
            </div>
            <div class="control-group">
                <div class="controls">

                    <button type="submit" class="btn btn-info">บันทึกข้อมูล</button>&nbsp;&nbsp;&nbsp;<button type="reset" class="btn">ยกเลิก</button>
                </div>
            </div>
        </div>
    </div>
</form>


<?php ?>
